<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>平台商品上下架</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		var subFlag = true;
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		//点击上架之后拼接参数，保持查询条件不会清空
		function up(obj,goodId){
			if(!subFlag){
				loading('正在提交，请稍等...');
				return;
			}
			obj.href = "${ctx}/sys/goodsPlatformUpDown/up?id="+goodId;
			if($("#queryPartsCode").val() != ""){
				obj.href += "&queryPartsCode="+$("#queryPartsCode").val();
			}
			if($("#queryMaterielCode").val() != ""){
				obj.href += "&queryMaterielCode="+$("#queryMaterielCode").val();
			}
			if($("#queryCnName").val() != ""){
				obj.href += "&queryCnName="+$("#queryCnName").val();
			}
			if($("#queryVenderName").val() != ""){
				obj.href += "&queryVenderName="+$("#queryVenderName").val();
			}
			if($("#queryStatus").val() != ""){
				obj.href += "&queryStatus="+$("#queryStatus").val();
			}
			if($("#starUpDate").val() != ""){
				obj.href += "&starUpDate="+$("#starUpDate").val();
			}
			if($("#endUpDate").val() != ""){
				obj.href += "&endUpDate="+$("#endUpDate").val();
			}
			subFlag = false;
		}
		
		//点击下架之后拼接参数，保持查询条件不会清空
		function down(obj,goodId){
			if(!subFlag){
				loading('正在提交，请稍等...');
				return;
			}
			if(confirm('确认要下架该商品吗？')){
				obj.href = "${ctx}/sys/goodsPlatformUpDown/down?id="+goodId;
				if($("#queryPartsCode").val() != ""){
					obj.href += "&queryPartsCode="+$("#queryPartsCode").val();
				}
				if($("#queryMaterielCode").val() != ""){
					obj.href += "&queryMaterielCode="+$("#queryMaterielCode").val();
				}
				if($("#queryCnName").val() != ""){
					obj.href += "&queryCnName="+$("#queryCnName").val();
				}
				if($("#queryVenderName").val() != ""){
					obj.href += "&queryVenderName="+$("#queryVenderName").val();
				}
				if($("#queryStatus").val() != ""){
					obj.href += "&queryStatus="+$("#queryStatus").val();
				}
				if($("#starUpDate").val() != ""){
					obj.href += "&starUpDate="+$("#starUpDate").val();
				}
				if($("#endUpDate").val() != ""){
					obj.href += "&endUpDate="+$("#endUpDate").val();
				}
			}else{
				return false;
			}
			subFlag = false;
		}
		
		function batchDown(){
			if(!subFlag){
				loading('正在提交，请稍等...');
				return;
			}
			
			if($("input[name=arrayId]:checked").length == 0){
				showTip("请先选择商品信息", "", 3000,0);
				return;
			}
			if(confirm('确认要下架该商品吗？')){
				$("#searchForm").attr("action","${ctx}/sys/goodsPlatformUpDown/batchDown");
				$("#searchForm").submit();
				subFlag = false;
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/goodsPlatformUpDown/">平台商品列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="goods" action="${ctx}/sys/goodsPlatformUpDown/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>配件编号：</label>
				<form:input path="queryPartsCode" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>物料编号：</label>
				<form:input path="queryMaterielCode" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>商品名称：</label>
				<form:input path="queryCnName" htmlEscape="false" maxlength="100" class="input-medium"/>
			</li>
			<li><label>制造商品牌：</label>
				<form:select path="queryVenderId" style="width:100px;">
					<option  value="">所有</option>
					<form:options items="${venderList}" itemLabel="name" itemValue="id" />
				</form:select>
			</li>
			<li class="clearfix"></li>
		</ul>
		<ul class="ul-form">
			<li><label>状态：</label>
				<form:select path="queryStatus" class="input-medium" >
					<option value="">所有</option>
					<c:forEach items="${dictList}" var="dict" > 
					 	<form:option value="${dict.value}">${dict.label}</form:option>
				  	</c:forEach>
				</form:select>
			</li>
			<li><label>上架时间：</label>
				<input id="starUpDate" name="starUpDate" type="text" readonly="readonly" placeholder="开始时间" class="input-medium Wdate " 
					value="<fmt:formatDate value="${goods.starUpDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
			        onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
			     	&nbsp;&nbsp;&nbsp;&nbsp;
			     <input id="endUpDate" name="endUpDate" type="text" readonly="readonly" placeholder="结束时间" class="input-medium Wdate " 
					value="<fmt:formatDate  value="${goods.endUpDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
			     	onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> 
			</li>
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
				<sys:storetypeselectForBatch id="batchUp" labelClass="btn btn-primary" labelName="上架"  url="${ctx}/sys/goodsPlatformUpDown/selectStoreList" checkBoxName="arrayId" suburl="${ctx}/sys/goodsPlatformUpDown/batchUp" />
				<input id="btnSubmit" class="btn btn-primary" type="button" onclick="batchDown()" value="下架"/>
			</li>
			<li class="clearfix"></li>
		</ul>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" name="allCheck" onclick="jp_allCheck(this,'arrayId')"/>序号</th>
				<th>物料编号</th>
				<th>配件编号</th>
				<th>商品编号</th>
				<th>商品名称</th>
				<th>制造商品牌</th>
				<th>售价</th>
				<th>会员价</th>
				<th>上次上架时间</th>
				<th>状态</th>
				<th>上架门店</th>
				<shiro:hasPermission name="sys:goodsPlatformUpDown:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="goods" varStatus="s">
			<tr>
				<td>
					<input type="checkbox" name="arrayId" value="${goods.id}" onclick="jp_oneCheck(this,'allCheck')"/>${s.index+1}
				</td>
				<td>
					${goods.materielCode}
				</td>
				<td>
					${goods.partsCode}
				</td>
				<td>
					${goods.code}
				</td>
				<td>
					<a href="${ctx}/sys/goodsplatformmanger/goodsDetail?goodsCode=${goods.code}&tagUrl=${ctx}/sys/goodsPlatformUpDown/list&tagName=平台商品列表">${goods.cnName}</a>
				</td>
				<td>
					${goods.venderName}
				</td>
				<td>
					${goods.price}
				</td>
				<td>
					${goods.memberPrice}
				</td>
				<td>
					<fmt:formatDate value="${goods.upDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<c:forEach items="${dictList}" var="bean">
						<c:if test="${goods.status == bean.value}">
							${bean.label}
						</c:if>
					</c:forEach>
				</td>
				<td>
					${goods.storeCnName}
				</td>
				<shiro:hasPermission name="sys:goodsPlatformUpDown:edit">
				<td>	
    				<c:choose>
    					<c:when test="${goods.status==0 || goods.status==2}">
    						<sys:storetypeselectForList id="${goods.id}" labelName="上架"  url="${ctx}/sys/goodsPlatformUpDown/selectStoreList" urlParam="?id=${goods.id}" suburl="${ctx}/sys/goodsPlatformUpDown/up" />
    					</c:when>
    					<c:when test="${goods.status==1}">
    					<sys:storetypeselectForList id="${goods.id}" labelName="调整" url="${ctx}/sys/goodsPlatformUpDown/selectStoreList" urlParam="?id=${goods.id}" suburl="${ctx}/sys/goodsPlatformUpDown/up" />
    						<a href="#" onclick="down(this,'${goods.id}')">下架</a>
    					</c:when>
    				</c:choose>
				</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</form:form>
	<form action="" id="storeForm" >
		<input type="hidden" id="id" name="id" />
		<input type="hidden" id="storeId" name="storeId" />
	</form>
	<div class="pagination">${page}</div>
</body>
</html>